import { useRoutes, type RouteObject } from 'react-router-dom';
import { lazy, type ReactNode } from 'react';

const Home = lazy(() => import('../pages/home'));
const Layout = lazy(() => import('../pages/layout'));
const News = lazy(() => import('../pages/news'));
const WebWorker = lazy(() => import('../pages/web-worker'));
const InputDome = lazy(() => import('../pages/input-event'));
const MessageNotification = lazy(() => import('../pages/message-notification'));
export interface RouteItem {
    path: string;
    name: string;
    element?: ReactNode;
    index?: boolean;
    type?: boolean;
    children?: RouteItem[];
}
const routerlist: RouteItem[] = [
    {
        path: '/',
        name: '第一条',
        element: <Layout />,
        children: [
            {
                path: '/',
                index: true,
                name: '首页',
                element: <Home />,
            },
            {
                path: '/news',
                name: '新闻',
                type: true,
                element: <News />,
            },
            {
                path: '/input-event',
                name: '合成事件',
                element: <InputDome />,
            },
            {
                path: '/message-notification',
                name: '消息通知',
                element: <MessageNotification />,
            },
            {
                path: '/web-worker12',
                name: '三级菜单',
                // element: <WebWorker></WebWorker>,
                children: [
                    {
                        path: '/web-worker12/news',
                        name: '新闻',
                        // type:true,
                        element: <News />,
                    },
                    {
                        path: '/web-worker12/input-event',
                        name: '合成事件',
                        element: <InputDome />,
                    },
                    {
                        path: '/web-worker12/web-worker',
                        name: 'WebWorker',
                        element: <WebWorker></WebWorker>,
                    },
                ],
            },
        ],
    },
    {
        path: '/web-worker',
        name: 'WebWorker',
        element: <WebWorker></WebWorker>,
    },
];
const Routers = () => {
    return useRoutes(routerlist as RouteObject[]);
};
export { routerlist };
export default Routers;
